package com.beta.rabbit.producer.broker;

import com.beta.rabbit.api.*;
import com.google.common.base.Preconditions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class ProducerClient implements MessageProducer {

    @Autowired
    RabbitBroker rabbitBroker;

    @Override
    public void send(Message message, SendCallback sendCallback) throws MessageRuntimeException {
        Preconditions.checkNotNull(message.getTopic());
        switch (message.getMessageType()){
            case MessageType.CONFIRM:
                rabbitBroker.confirmSend(message);
                break;
            case MessageType.RAPID:
                rabbitBroker.rapidSend(message);
                break;
            case MessageType.RELIANT:
                rabbitBroker.reliantSend(message);
                break;
        }
    }

    @Override
    public void send(Message message) throws MessageRuntimeException {

    }

    @Override
    public void send(List<Message> messages) throws MessageRuntimeException {

    }
}
